﻿@{
    ViewBag.Title = "Administrar Lugares";
}

<br />
<div id="LugarTable"></div>

@section Scripts {
    <script type="text/javascript">
        $(document).ready(function () {
            $('#LugarTable').jtable({
                title: '@ViewBag.Title',
                paging: true,
                pageSize: 25,
                sorting: true,
                multiSorting: true,
                defaultSorting: 'nombre ASC',
                actions: {
                    listAction: '@Url.Action("LugarList","Catalogo")',
                    deleteAction: '@Url.Action("DeleteLugar","Catalogo")',
                    updateAction: '@Url.Action("UpdateLugar","Catalogo")',
                    createAction: '@Url.Action("CreateLugar","Catalogo")'
                },
                fields: {
                    idLugar: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    nombre: {
                        title: 'Nombre',
                        inputClass: 'validate[required,maxSize[45]]'
                    },
                    idPais: {
                        title: 'Pais',
                        inputClass: 'validate[required]',
                        options: '@Url.Action("GetPaisOptions","Catalogo")'
                    },
                    direccion: {
                        title: 'Dirección',
                        list: false,
                        type: 'textarea',
                        inputClass: 'validate[maxSize[100]]'
                    }
                },
                formCreated: function (event, data) {
                    data.form.validationEngine();
                },
                formSubmitting: function (event, data) {
                    return data.form.validationEngine('validate');
                },
                formClosed: function (event, data) {
                    data.form.validationEngine('hide');
                    data.form.validationEngine('detach');
                }
            });

            $('#LugarTable').jtable('load');
        });
    </script>
}